# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Contributor: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Jaroslaw Swierczynski <swiergot@aur.archlinux.org>
# Contributor: Roman Kyrylych <Roman.Kyrylych@gmail.com>

pkgname=glob2
pkgver=0.9.4.4
pkgrel=46
pkgdesc='An innovative Real-Time Strategy game which reduces micro-management by automatically assigning tasks to units'
arch=('loong64' 'x86_64')
url='https://www.globulation2.org/'
license=('GPL3')
depends=('boost-libs' 'sdl_net' 'sdl_image' 'sdl_ttf' 'libvorbis' 'speex' 'glu'
         'fribidi' 'xdg-utils' 'libgl' 'hicolor-icon-theme')
makedepends=('scons' 'boost' 'mesa' 'patch')
source=(https://dl.sv.nongnu.org/releases/$pkgname/${pkgver%.*}/$pkgname-$pkgver.tar.gz
        glob2-0.9.4.1-gcc44.patch fix-ftbfs-gcc49.diff
        glob2-gcc6.patch
        glob2-scons3.patch
        glob2-bool.patch
        scons-python3.patch)
sha256sums=('0f4d898ec6b05ce27b4a12ef242cc26571304b90d2509932a4743c71311314b8'
            '3a0cfc06696d1aaf2d7948b5f6a09a8ce96492767039dc09bfc25182b92d7b7a'
            '2bf0e51ca5de8c6f4910b68522a0265e07bb32beefe13b9912b59e5954c5bfba'
            'a371eb801407a75021c1a0105ffa1e713358d7def3eba8a9bd861f528e051d9b'
            '4b7833d58d62abb8c737cb60e959fe3bb27cc4a19917e4fd5fca7a7debada5cc'
            '81d28fde429be01ae2398ca33537daf9203bafb45182d51f04b2d00dd173b591'
            '6daec0ee916f6bbc4e9696a0a713e2b06e4951381d508af814e67e980bd28664')

prepare() {
  cd "$pkgname-$pkgver"

  patch -p0 -i "$srcdir/glob2-0.9.4.1-gcc44.patch"
  patch -p1 -i "$srcdir/fix-ftbfs-gcc49.diff"
  patch -p1 -i "$srcdir/glob2-gcc6.patch"
  patch -p1 -i "$srcdir/glob2-scons3.patch"
  patch -p1 -i "$srcdir/glob2-bool.patch"
  patch -p1 -i ../scons-python3.patch
}

build() {
  cd "$pkgname-$pkgver"

  scons LINKFLAGS="-lboost_system"
}

package () {
  cd "$pkgname-$pkgver"

  scons install BINDIR="$pkgdir/usr/bin" INSTALLDIR="$pkgdir/usr/share"
  find "$pkgdir/usr/share" -type f -exec chmod 644 '{}' \;
  install -Dm644 "data/icons/$pkgname-icon-48x48.png" \
    "$pkgdir/usr/share/pixmaps/$pkgname-icon-48x48.png"
}
